<?php
$pageTitle = '添加文章';
include 'header.tpl.php';
?>
<script type="text/javascript">
$(document).ready(function(){
	$('#up-pic').upload({
		field: 'pic'
	})
})
</script>
<form action="<?php echo $router;?>" method="post">
<ul>
<li>
	<label for="cid">所属栏目 </label>
		<select name="cid">
		<option value="0">选择栏目 </option>
		<?php foreach ($catalogList as $item):?>
		<option <?php if ($arr['cid']==$item['id']):?>selected="selected"<?php endif;?> value="<?php echo $item['id'];?>"><?php echo str_repeat('-', $item['level']-1) . $item['name'];?></option>
		<?php endforeach;?>
		</select>
</li><li>
	<label for="title">文章标题</label>
		<input type="text" name="title" value="<?php echo $arr['title'];?>" />
</li><li>
	<label for="flag">标识属性</label>
		<?php foreach ($flags as $key=>$flag):?>
		<input type="checkbox" name="flag[]" <?php if (in_array($key, $arr['flag'])):?>checked="checked"<?php endif;?> value="<?php echo $key;?>" /><?php echo $flag;?>
		<?php endforeach;?>
</li><li>
	<label for="pic">标题图片</label>
		<input type="text" name="pic" id="pic" value="<?php echo $arr['pic'] ? APP_HOST . $arr['pic'] : '';?>">
		<span><input type="checkbox" name="checkFirstPic" checked="checked" value="1">提取文章首图</span>
		<span class="button" id="up-pic">上传</span>
		<span class="button" onclick="window.open(document.getElementById('pic').value);">&nbsp;预览</span>
</li><li>
	<label for="priority">置顶</label>
		<input type="text" name="priority" value="<?php $toptime = $arr['priority']-time(); echo $toptime>0 ? ceil($toptime/86400) : '';?>" /><span style="disply:block;float:left">天置顶</span>
</li><li>
	<label for="author">作者</label>
		<input type="text" name="author" value="<?php echo $arr['author'];?>" />
</li><li>
<textarea name="memo" class="kindEditor"><?php echo $arr['memo'];?></textarea>
</li><li>
	<input type="hidden" name="act" value="<?php echo isset($act)?$act:'add';?>" />
	<input type="hidden" name="aid" value="<?php echo $arr['id'];?>" />
	<button type="submit">提交</button><button type="reset">取消</button>
</li>
</ul>
</form>


<?php include 'footer.tpl.php';?>

<script type="text/javascript">
var editor;
KindEditor.ready(function(K) {
    editor = K.create('.kindEditor', {
		width: '99%',
		height: '500px',
		items: [
		        'source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'cut', 'copy', 'paste',
		        'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
		        'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
		        'superscript', 'clearhtml', 'quickformat', 'selectall', '|',
		        'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
		        'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'image',
		        'flash', 'media', 'insertfile', 'table', 'hr', 'emoticons', 'map', 'code', 'pagebreak',
		        'link', 'unlink', '|', 'about'
		]
    });
});
</script>